<template>
	<view class="indent-details">
		<view v-if="listData.status == 6" class="i-d-title">
			<text class="i-d-t-text">评价完成</text>
			<text class="i-d-t-text1">感谢您的反馈，我们会继续努力给您更好的服务体验</text>
		</view>
		<view v-else class="i-d-title">
			<text class="i-d-t-text">{{title || ''}}</text>
			<text class="i-d-t-text1">{{['保洁阿姨已接单，请您耐心等待','保洁阿姨正在清洁中','','您的订单已完成','计划有变，不需要了'][index]}}</text>
		</view>
		<view class="i-d-top">
			<view v-if="listData.status == 6" class="o-t-title1">
				<view class="t-con-text">
					<text class="t-c-text">我的评价</text>
					<uni-rate :value="listData.evaluate.star" :readonly="true" color="#FFE9BB" active-color="#FEAD1D" />
				</view>
				<view class="sub-ev-tag">
					<uni-tag class="ev-tag" :text="item" v-for="(item,index) in label" :key="index"
						custom-style="background-color: #F6F6F6; border: 0; color: #737373;border-radius:8rpx;">
					</uni-tag>
				</view>
				<text class="sub-ev-text">{{listData.evaluate.content || ''}}</text>
			</view>
			<view v-else class="o-t-title">
				<image class="o-t-t-img" :src="imgUrl" mode="aspectFit"></image>
				<view class="o-t-t-con">
					<view class="t-con-text">
						<view>
							<text class="t-c-text">{{listData.address_info.a_name || ''}}</text>
							<text class="t-c-text">{{listData.address_info.tel || ''}}</text>
						</view>
					</view>
					<view class="t-con-text1">
						<text class="t-c-text1">{{listData.address_info.road || ''}}</text>
					</view>
				</view>
			</view>
			<view class="o-t-body">
				<uni-card v-if="index == 0 || index == 4" title="预约信息" :extra="listData.service_time" :is-shadow="false" :border="false" :margin="'0 0 20rpx 0'" :spacing="'20rpx 40rpx'" :padding="0">
					<view class="yuyue">
						<view class="yuyue-header" >
							<image class="yuyue-header-image" :src="listData.cleaner_info.avatar[0]" mode="" @click="lookImg(listData.cleaner_info.avatar[0])"></image>
						</view>
						<view class="yuyue-main">
							<view class="main-name">
								{{listData.cleaner_info.real_name || listData.cleaner_info.nickname}}
							</view>
							<view class="main-score-ioc">
								<view class="dis-corder"><image class="img-14" :src="imgUrl3" mode="aspectFit" /><text style="color: #FEAD1D;">{{listData.cleaner_info.score || ''}}</text></view>
								<text class="ioc-text">已服务 {{listData.cleaner_info.services_num || '0'}}次</text>
							</view>
						</view>
					</view>
				</uni-card>
				<template v-else>
				<uni-card title="房间信息" :is-shadow="false" :border="false" :margin="'0 0 20rpx 0'" :spacing="'20rpx 40rpx'" :padding="0">
					<uni-list :border="false">
						<uni-list-item :border="false" v-for="obj in listData.rooms" :key="obj.id">
							<!-- 自定义 body -->
							<view slot="body" class="slot-box slot-main">
								<image class="slot-main-image" :src="obj.room_type_image[0]" mode=""></image>
								<view class="slot-main-con">
									<view class="main-con">
										<text class="name">{{obj.room_name || ''}}</text>
										<view class="">
											<text class="money">￥</text>
											<text class="name">{{obj.hotel_price || '0.00'}}</text>
										</view>
									</view>
									<view class="main-con score">
										<text class="type">{{obj.type_name || ''}}</text>
									</view>
								</view>
							</view>
						</uni-list-item>	
					</uni-list>
				</uni-card>
				<uni-card title="服务详情" :is-shadow="false" :border="false" :margin="'0 0 20rpx 0'" :spacing="'20rpx 40rpx'" :padding="0">
					<view class="xiangqing">
						<view class="o-t-box">
							<text class="t-box-text">服务员</text>
							<text class="t-box-text1">{{listData.cleaner_info.real_name || listData.cleaner_info.nickname}}</text>
						</view>
						<view class="o-t-box">
							<text class="t-box-text">服务时间</text>
							<text class="t-box-text1">{{listData.service_time || ''}}</text>
						</view>
						<view class="o-t-box">
							<text class="t-box-text">订单总额</text>
							<view>
								<text class="t-box-text2">￥</text><text class="t-box-text2 t-box-text3">{{listData.totalmoney || '0.00'}}</text>
							</view>
						</view>
						<view class="o-t-box1">
							<view class="t-box-text">备注信息</view>
							<text class="t-box-text1">{{listData.remarks == null?'未添加备注信息':listData.remarks}}</text>
						</view>
					</view>
				</uni-card>
				</template>
				<uni-card title="订单详情" :is-shadow="false" :border="false" :margin="'0 0 20rpx 0'" :spacing="'20rpx 40rpx'" :padding="0">
					<view class="dindan">
						<text class="dindan-text">订单编号：</text>
						<text class="dindan-text1">{{listData.order_num || ''}}</text>
					</view>
					<view class="dindan">
						<text class="dindan-text">下单时间：</text>
						<text class="dindan-text1">{{listData.create_time || ''}}</text>
					</view>
					<view v-if="index == 3" class="dindan">
						<text class="dindan-text">付款时间：</text>
						<text class="dindan-text1">{{listData.hotel_pay_time || ''}}</text>
					</view>
					<view v-if="index == 4" class="dindan">
						<text class="dindan-text">取消时间：</text>
						<text class="dindan-text1">{{listData.hotel_cancel_time || ''}}</text>
					</view>
				</uni-card>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgUrl:`${getApp().globalData.imgScr}jd/dizhi_xiangqiye.png`,
				imgUrl3:`${getApp().globalData.imgScr}jd/xinji.png`,
				title:'', // 订单标题
				index:'', //  进入订单的页面id 用于判断显示的数据
				listData: [], //请求详情数据
				label:[], // 评价标签
			}
		},
		onLoad(e) {
			this.title = e.title
			this.index = e.index
			this.getClick(e.id)
		},
		methods: {
			/**
			 * 请求数据
			 */
			async getClick(id) {
				try{
					let res = await this.$http.post('/index/Communal/orderinfo',{
						id:id
					})
					this.listData = res
					this.label = res.evaluate.label.split(',')
				}catch(e){
					//TODO handle the exception
					uni.showToast({
						title: e.errMsg,
						icon:"none"
					})
				}
			},
			
		}
	}
</script>

<style lang="scss">
	.indent-details {
		position: relative;
		width: 100%;
		// 顶部标题栏样式
		.i-d-title {
			display: flex;
			flex-direction: column;
			box-sizing: border-box;
			width: 100%;
			height: 230rpx;
			background: linear-gradient(-90deg, #8dc9f1, #d8eefc);
			padding: 20rpx 40rpx;
			.i-d-t-text {
				font-size: 40rpx;
				font-weight: bold;
				color: #FFFFFF;
				margin-bottom: 20rpx;
			}
			.i-d-t-text1 {
				font-size: 28rpx;
				font-weight: 500;
				color: #FFFFFF;
			}
		}
		//内容区域样式
		.i-d-top {
			position: absolute;
			top: 150rpx;
			left: 0;
			box-sizing: border-box;
			width: 100%;
			display: flex;
			flex-direction: column;
			margin-bottom: 20rpx;
			overflow: hidden;
			padding: 0 20rpx;

			// 顶部标题栏样式
			.o-t-title {
				display: flex;
				align-items: center;
				width: 100%;
				height: 140rpx;
				box-sizing: border-box;
				padding: 20rpx 40rpx;
				margin-bottom: 20rpx;
				border-radius: 20rpx;
				background-color: #FFFFFF;
				overflow: hidden;

				.o-t-t-img {
					width: 44rpx;
					height: 44rpx;
					margin-right: 20rpx;
				}

				.o-t-t-con {
					flex: 1;
					display: flex;
					flex-direction: column;
					justify-content: center;

					.t-con-text {
						display: flex;
						justify-content: space-between;
						align-items: center;

						.t-c-text {
							font-size: 28rpx;
							font-weight: 500;
							color: #000000;
							margin-right: 30rpx;
						}
					}

					.t-con-text1 {
						.t-c-text1 {
							font-size: 24rpx;
							font-weight: 500;
							color: rgba($color: #000000, $alpha: 0.7);
							margin-right: 30rpx;
						}
					}
				}
			}
			
			// 顶部标题栏样式
			.o-t-title1 {
				display: flex;
				flex-direction: column;
				width: 100%;
				box-sizing: border-box;
				padding: 20rpx 40rpx;
				margin-bottom: 20rpx;
				border-radius: 20rpx;
				background-color: #FFFFFF;
				overflow: hidden;
			
				.t-con-text {
					display: flex;
					align-items: center;
					margin-bottom: 20rpx;
					.t-c-text {
						font-size: 28rpx;
						font-weight: 500;
						color: #000000;
						margin-right: 20rpx;
					}
					.uni-rate__icon {
						margin-right: 6rpx!important;
						.uni-icons {
							font-size: 40rpx!important;
						}
					}
				}
				.sub-ev-tag {
					display: flex;
					align-items: center;
					flex-wrap: wrap;
					.ev-tag {
						margin:0 20rpx 20rpx 0;
					}
				}
				.sub-ev-text {
					font-size: 24rpx;
					font-weight: 500;
					color: rgba($color: #000000, $alpha: 0.7);
					margin-bottom: 20rpx;
					line-height: 1.5em;
				}
				
			}

			// 中间 列表栏样式
			.o-t-body {
				// flex: 1;
				// overflow: auto;
				.yuyue {
					display: flex;
					align-items: center;
					.yuyue-header {
						margin-right: 24rpx;
						.yuyue-header-image {
							width: 100rpx;
							height: 100rpx;
							border-radius: 20rpx;
							border: 0;
						}
					}
					.yuyue-main {
						flex: 1;
						display: flex;
						flex-direction: column;
						height: 100rpx;
						.main-name {
							font-size: 28rpx;
							color: #000000;
							font-weight: 500;
						}
						.main-score-ioc {
							display: flex;
							font-size: 24rpx;
							color: rgba($color: #000000, $alpha: 0.5);
							.dis-corder {
								display: flex;
								align-items: center;
								margin-right: 32rpx;
								.img-14 {
									width: 28rpx;
									height: 28rpx;
									margin: 8rpx;
								}
							}
							.ioc-text {
								font-size: 24rpx;
								font-weight: 500;
								color: rgba($color: #000000, $alpha: 0.5);
							}
						}
					}
				}

				// 列表每一项内容的样式
				.uni-list-item__container {
					box-sizing: border-box;
					padding: 20rpx 0;
				}

				// 列表区域 自定义 header body 公共样式
				.slot-box {
					display: flex;
					align-items: center;
				}
				// 卡片公共样式
				.uni-card {
					border-radius: 20rpx;
					overflow: hidden;
					.uni-card__header {
						padding: 20rpx 0;
						.uni-card__header-content-title {
							font-size: 28rpx;
							font-weight: 600;
							color: #000000;
						}
					}
					
				}
				// 列表区域 自定义 body 的样式
				.slot-main {
					flex: 1;

					// 列表区域 图片样式
					.slot-main-image {
						width: 100rpx;
						height: 100rpx;
						border-radius: 20rpx;
						border: 0;
					}

					// 列表区域 详情信息 样式
					.slot-main-con {
						flex: 1;
						display: flex;
						flex-direction: column;
						margin-left: 16rpx;
						padding-right: 24rpx;

						.main-con {
							flex: 1;
							display: flex;
							justify-content: space-between;
							align-items: center;
							color: #000000;
							.name {
								font-size: 34rpx;
								font-weight: 500;
							}
							.money {
								font-size: 20rpx;
								font-weight: 500;
							}
							.type {
								font-size: 28rpx;
								font-weight: 500;
							}
						}
						.score {
							margin: 12rpx 0;
						}
					}
				}

				// 详情栏 样式
				.xiangqing {
					background-color: #FFFFFF;

					.o-t-box {
						display: flex;
						justify-content: space-between;
						align-items: center;
						margin-bottom: 20rpx;

						.t-box-text {
							font-size: 28rpx;
							font-weight: 500;
							color: rgba($color: #000000, $alpha: 0.7);
						}
						.t-box-text1 {
							font-size: 28rpx;
							font-weight: 500;
							color: #000000;
						}
						.t-box-text2 {
							font-size: 28rpx;
							font-weight: 500;
							color: #FF4B4B;
						}
						.t-box-text3 {
							font-size: 34rpx;
							font-weight: 500;
						}	
					}
					.o-t-box1 {
						display: flex;
						flex-direction: column;
						
						.t-box-text {
							font-size: 28rpx;
							font-weight: 500;
							color: rgba($color: #000000, $alpha: 0.7);
							margin-bottom: 20rpx;
						}
						.t-box-text1 {
							box-sizing: border-box;
							min-height: 200rpx;
							font-size: 28rpx;
							font-weight: 500;
							color: #000000;
							border-radius: 4px;
							border: 1px solid #F0F0F0;
							padding: 20rpx;
							margin-bottom: 20rpx;
						}
					}
				}
			}
		}

		// 订单详情卡片
		.dindan {
			margin-bottom: 20rpx;
			.dindan-text {
				font-size: 28rpx;
				font-weight: 500;
				color: rgba($color: #000000, $alpha: 0.7);
			}
			.dindan-text1 {
				font-size: 28rpx;
				font-weight: 500;
				color: #000000;
			}
		}
	}
</style>
